package com.twu.biblioteca;

import Controller.*;
import Model.*;
import Persistance.BookList;
import Persistance.MovieList;
import Persistance.UserList;


public class BibliotecaApp {
    public static final int LAST_MENU_ITEM = 5;
    public static final int EXIT_MENU_OPTION = 5;

    public static Library library;
    public static Session session;
    public static KeyboardUserInput keyInput;
    public UserController userController;
    public BookController bookController;
    public MovieController movieController;
    public ReserveBookController reserveBookController;
    public HomeController homeController;

    public BibliotecaApp(){
        library = new Library(new BookList(), new MovieList(), new UserList());
        session = new Session(library.getUserList());
        keyInput = new KeyboardUserInput();
        bookController = new BookController();
        movieController = new MovieController();
        userController = new UserController();
        reserveBookController = new ReserveBookController();
        homeController = new HomeController();
    }

    private void functionInvoker(int choice){
        if (choice == 1){
            bookController.showBooks();
        }
        if (choice == 2){
            movieController.showMovies();
        }
        if (choice == 3)
            userController.showUserDetails(session);

        if(choice == 4 && session.isUserLoggedIn()){
            reserveBookController.reserveBook();

        }

    }

    public void start(){
        int choice;
        homeController.showWelcomeMessage();

        do{
            choice = homeController.showMenu();
            functionInvoker(choice);
        }while (choice != EXIT_MENU_OPTION);
    }

    public static void main(String[] args){

        BibliotecaApp app = new BibliotecaApp();
        app.start();

    }





}
